feat: [OpenAI] Release OpenAI Responses API #910
Conversation
- Streaming no fully enabled
* Minimal new module setup including spec * Generation partial-success * Remove examples * Successfully filter by path * Attach spec filter command * Initial setup * Successful PoC with OpenAI Models * Version 1 * Stable api * Change class name * Add tests * fix dependency analyse issues * Initial draft untested * Second draft - Streaming no fully enabled * Successful E2E * Streaming initial draft * Streaming E2E with chat completion * isStreaming check simplified * Cleanup PoC and rename module * Reduce Javadoc verbosity * Restrict to `/responses` api * Cleanup comments * Charles review suggestions * Charles review - round 2 suggestions * Add dependency * Mark openai dependency optional and new client `@Beta` * Cleanup and no throw on missing model * pmd * Responses API complete * ChatCompletionCreateParams throws without model. Needs rethink client API creation forModel * Cleanup and close with test documenting limitation * First draft responses only * jacoco limits * Remove ResponseService wrapper since remote API behaviour changed
…nses-apache # Conflicts: # sample-code/spring-app/pom.xml
# Conflicts: # docs/release_notes.md # pom.xml
|
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Jonas-Isr
left a comment
There was a problem hiding this comment.
The code looks good overall! I had a few comments and one question:
Would it make sense to also test the other features mentioned in the md file, like reasoning effort, background mode etc in the e2e tests? Then we would also have code examples for those features that we could put into the documentation.
| * <p>This class provides factory methods that return fully configured OpenAI SDK clients using SAP | ||
| * Cloud SDK's Apache HttpClient with automatic OAuth token refresh. | ||
| * | ||
| * @since 1.19.0 |
There was a problem hiding this comment.
(Minor)
Maybe also elsewhere?
| * @since 1.19.0 | |
| * @since 1.21.0 |
| @Test | ||
| void testCreateStreamingResponse() { | ||
| try (var stream = service.createStreamingResponse("What is the capital of France?")) { | ||
| stream.stream() | ||
| .forEach( | ||
| event -> { | ||
| assertThat(event.isValid()).isTrue(); |
There was a problem hiding this comment.
When I run this test locally it fails for the assertion in line 44 😬
| Map.of( | ||
| "/responses", Set.of("POST"), | ||
| "/responses/[^/]+", Set.of("GET", "DELETE"), | ||
| "/responses/[^/]+/cancel", Set.of("POST")); |
There was a problem hiding this comment.
(Question)
Would not /responses/[^/]+ match everything that is matched by /responses/[^/]+/cancel? In that case we rely on the implicit ordering of the HashMap in lines 91 onward to find the correct entry. That would be dangerous I think.
| if (event.isCompleted()) { | ||
| final var completed = event.asCompleted().response(); | ||
|
|
||
| final var usage = completed.usage().orElseThrow(); | ||
| assertThat(usage.inputTokens()).isEqualTo(13L); | ||
| assertThat(usage.outputTokens()).isEqualTo(59L); | ||
| assertThat(usage.totalTokens()).isEqualTo(72L); | ||
|
|
||
| final var output = completed.output(); | ||
| assertThat(output).isNotNull(); | ||
| final var item1 = output.get(0); | ||
| assertThat(item1.isReasoning()).isTrue(); | ||
| final var item2 = output.get(1); | ||
| assertThat(item2.isMessage()).isTrue(); | ||
| assertThat(item2.asMessage().content()).isNotEmpty(); | ||
| final ResponseOutputMessage.Content content = item2.asMessage().content().get(0); | ||
| assertThat(content.isOutputText()).isTrue(); | ||
| assertThat(content.asOutputText().text()).contains("lemonade"); | ||
| } |
There was a problem hiding this comment.
(Major)
The code inside this IF block is never reached (you can check in the debugger). Thus, these assertions are never checked.
| <dependency> | ||
| <groupId>com.openai</groupId> | ||
| <artifactId>openai-java-client-okhttp</artifactId> | ||
| <version>${openai-java.version}</version> | ||
| </dependency> |
There was a problem hiding this comment.
(Question)
Is this dependency used somewhere?
Context
AI/ai-sdk-java-backlog#390.
Stability concerns about AI Proxy are tackled now supporting new endpoints and documenting Responses API.
Feature scope:
Definition of Done
Aligned changes with the JavaScript SDK